package com.umanji.enterprise.service;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

// import com.umanji.user.dao.UserDao;
import com.umanji.generic.service.GenericService;
import com.umanji.building.domain.Buildings;
import com.umanji.enterprise.domain.Enterprises;
import com.umanji.enterprise.domain.ServiceItems;

@Service("svcItemService")
@Transactional(propagation=Propagation.SUPPORTS, readOnly=true)
public class SvcItemServiceImpl extends GenericService<ServiceItems, Long> implements SvcItemService {

	private final Log log = LogFactory.getLog ( SvcItemServiceImpl.class );

	@Override
	public List<ServiceItems> findByCode(String category_code) {
		// TODO Auto-generated method stub
		return super.em.createQuery("Select e from " + ServiceItems.class.getSimpleName() + " e where e.category_code = :category_code").setParameter("category_code", category_code).getResultList();
	}

	@Override
	public List<ServiceItems> findRootCategories() {
		return super.em.createQuery("Select e from " + ServiceItems.class.getSimpleName() + " e where e.parent is null").getResultList();
    }
}
